home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / qbser21.zip / PCBDOOR.BAS < prev    next >
BASIC Source File  |  1990-10-31  |  6KB  |  194 lines

  1.     DEFINT A-Z
  2. '   $INCLUDE: 'QBSERIAL.DEC'
  3.  
  4. '   This is only an example base for doing a door. It just demonstrates
  5. '   how to obtain certain PCBoard parameters and apply them to QBserial.
  6. '   It is not guarenteed to work if added on to. It was written while
  7. '   PCBoard 14.0 was current. Certain parameter may have changed in PCBoard
  8. '   since then.
  9.  
  10.     CRLF$ = CHR$(13) + CHR$(10)
  11.  
  12. '   Pick up name of config file with COMMAND$, then open and parse the file
  13. '   extracting what you need. You'll recognize the parameters. Substitute
  14. '   new names for parameters you door needs. Some of these (perhaps all?)
  15. '   you can leave intact and use.
  16.     
  17.     IF FileExists(COMMAND$ + CHR$(0)) THEN
  18.         OPEN COMMAND$ FOR INPUT ACCESS READ SHARED AS #1
  19.         WHILE NOT EOF(1)
  20.             LINE INPUT #1, A$
  21.             A$ = UCASE$(A$)
  22.             IF INSTR(A$, "FILES=") THEN
  23.                 X = INSTR(A$, "=")
  24.                 Files$ = MID$(A$, X + 1)
  25.             ELSEIF INSTR(A$, "INTRO=") THEN
  26.                 X = INSTR(A$, "=")
  27.                 Intro$ = MID$(A$, X + 1)
  28.             ELSEIF INSTR(A$, "CARRIER=") THEN
  29.                 X = INSTR(A$, "=")
  30.                 CarrierDetect$ = MID$(A$, X + 1)
  31.             ELSEIF INSTR(A$, "HANDSHAKE=") THEN
  32.                 X = INSTR(A$, "=")
  33.                 Handshake$ = MID$(A$, X + 1)
  34.             END IF
  35.         WEND
  36.         CLOSE #1
  37.     ELSE
  38.         PRINT "SYSOP: Configuration file cannot be found. Program returning"
  39.         END
  40.     END IF
  41.  
  42.     PCBoardDat$ = "PCBoard.Dat"
  43.     PCBoardSys$ = "PCBoard.Sys"
  44.  
  45.     IF FileNotFound(PCBoardSys$ + CHR$(0)) THEN
  46.         PRINT "SYSOP: Cannot find PCBoard.Sys, are you in the right DIR?"
  47.         END
  48.     END IF
  49.     IF FileNotFound(PCBoardDat$ + CHR$(0)) THEN
  50.         PRINT "SYSOP: Cannot find PCBoard.Dat, are you in the right DIR?"
  51.         END
  52.     END IF
  53.  
  54.     SELECT CASE Handshake$      ' Set the proper Handshake
  55.         CASE "XON"
  56.             HS = 1
  57.         CASE "CTS"
  58.             HS = 2
  59.         CASE "BOTH"
  60.             HS = 3
  61.         CASE ELSE
  62.             HS = 0
  63.     END SELECT
  64.  
  65. '   Extract parameters from PBOARDS.SYS & PCBOARD.DAT
  66. '   Callers$ = Location of the callers log (with node number tacked on)
  67. '   Port = The comm port number
  68. '   CurrentBaud$ = The current baud rate or LOCAL
  69. '   Node = Current Node (if used)
  70.  
  71.     OPEN PCBoardSys$ FOR RANDOM ACCESS READ SHARED AS #7 LEN = 128
  72.     FIELD #7, 128 AS Board$
  73.     GET #7, 1
  74.     OPEN PCBoardDat$ FOR INPUT AS #1
  75.     LINE INPUT #1, A$
  76.     FOR Lp = 1 TO 28
  77.         INPUT #1, A$
  78.     NEXT Lp
  79.     INPUT #1, Callers$
  80.     CLOSE #1
  81.     Node = ASC(MID$(Board$, 112, 1))
  82.     IF Node THEN
  83.         Callers$ = Callers$ + MID$(STR$(Node), 2)
  84.     END IF
  85.     CurrentBaud$ = LTRIM$(RTRIM$(UCASE$(MID$(Board$, 19, 5))))
  86.     Port = VAL(MID$(Board$, 126, 1))
  87.  
  88. '   Comm port initilization call format:
  89.  
  90. '   OpenComm Port%, IRQ%, Wordlen%, Parity%, Baudrate&, Handshake%
  91.  
  92. '   NOTICE: The Baudrate, Parity & Wordlength ARE NOT CHANGED!! (Passed as 0)
  93. '   WHY? Because why change them when they are already set the way you
  94. '   want them.
  95.  
  96.     IF CurrentBaud$ = "LOCAL" THEN
  97.         OpenComm 0, 0, 0, 0, 0, 0, 0       'This NEEDS to be here like this
  98.                                         'so calls to Transmit will return
  99.                                         'properly when in local. No data is
  100.                                         'transmitted when in this condition
  101.     ELSE
  102.         OpenComm Port, 0, 0, 0, 0, 0, HS
  103.     END IF
  104.          
  105. '   Enable Carrier Detect trap ONLY if NOT in Local and NOT disabled by the
  106. '   Sysop
  107.  
  108.     IF CarrierDetect$ <> "NO" AND MID$(CurrentBaud$, 1, 4) <> "LOCA" THEN
  109.         ON UEVENT GOSUB SysopClose
  110.         UEVENT ON
  111.     END IF
  112.  
  113. '***************************************************************************
  114. '   Your CODE goes here. Heres an example:
  115.  
  116.     ' To send data out
  117.  
  118.     Temp$ = "This is transmitted out the serial port." + CRLF$
  119.     Transmit Temp$
  120.  
  121.     'To get data from remote (or local) keyboard.
  122.  
  123.     Temp$ = "Enter data: "
  124.     PRINT Temp$
  125.     Transmit Temp$
  126.     Transmit CRLF$
  127.     GOSUB KeyboardInput
  128.     Temp$ = "You entered: " + A$
  129.     PRINT Temp$
  130.     Transmit Temp$
  131.     Transmit CRLF$
  132.  
  133. '   Your code ends here
  134. '****************************************************************************
  135.  
  136.     'VERY important ending step - if you forget this, you CRASH sometime later.
  137.     'But ONLY restore the vectors if you actually took them, otherwise
  138.     'you'll cause a crash for other reasons.
  139.  
  140. RestoreInt:
  141.  
  142.     IF MID$(CurrentBaud$, 1, 4) <> "LOCA" THEN
  143.         CloseComm
  144.     END IF
  145.     END
  146.  
  147. SysopClose:
  148.  
  149.     CLS
  150.     Temp$ = "Loss of Carrier has been detected."
  151.     PRINT Temp$
  152.     GOTO RestoreInt
  153.  
  154.     'Keyboard input scan. Fetches characters from the remote keyboard.
  155.     'Echo's characters as enetered. Returns on carriage return.
  156.  
  157. KeyboardInput:
  158.  
  159.     A$ = ""
  160.     InCount = 0
  161.     ClearInputBuffer
  162.     DO
  163.         DO
  164.             Hit$ = INKEY$
  165.             IF Hit$ <> "" THEN EXIT DO
  166.         LOOP UNTIL DataWaiting
  167.         I$ = ""
  168.         IF Hit$ = "" THEN
  169.             DO WHILE DataWaiting
  170.                 I$ = I$ + CHR$(ReadChar)
  171.             LOOP
  172.         ELSE
  173.             I$ = Hit$
  174.         END IF
  175.         TookIn = LEN(I$)
  176.         IF I$ = CHR$(8) THEN
  177.             IF InCount THEN
  178.                 ' Your code to handle Backspace key ********
  179.                 ' Dont forget to send the Backspace sequence out to the
  180.                 ' Com port also with Transmit
  181.             END IF
  182.         END IF
  183.         IF I$ = CHR$(13) THEN EXIT DO
  184.         I$ = UCASE$(I$)
  185.         IF I$ > CHR$(&H1F) AND I$ < CHR$(&H7F) THEN
  186.             Transmit I$
  187.             PRINT I$;   ' You may need to echo in a different way *******
  188.             A$ = A$ + I$
  189.             InCount = InCount + TookIn
  190.         END IF
  191.     LOOP
  192.     RETURN
  193.  
  194.